package com.teacher.pojo.enums.items;

import java.math.BigDecimal;

public enum TeacherType {
    /**
     * 10 教师资格证 一门笔试 0.2
     * 20 教师资格证 两门笔试 0.4
     * 30 教师资格证 笔试面试全过 1
     */
    A(10, new BigDecimal("0.2"), "一门笔试"),
    B(20, new BigDecimal("0.4"), "两门笔试"),
    C(30, new BigDecimal("1"), "笔试面试全过");
    private Integer code;
    private BigDecimal grades;
    private String name;

    TeacherType(Integer code, BigDecimal grades, String name) {
        this.grades = grades;
        this.code = code;
        this.name = name;
    }

    /**
     * 通过code拿到名称
     *
     * @param type
     * @return
     */
    public static String getNameByCode(Integer type) {
        for (TeacherType eType : TeacherType.values()) {
            if (eType.code.equals(type)) {
                return eType.name;
            }
        }
        return "0";
    }

    /**
     * 通过code拿到分数
     *
     * @param type
     * @return
     */
    public static BigDecimal getGradesByCode(Integer type) {
        for (TeacherType eType : TeacherType.values()) {
            if (eType.code.equals(type)) {
                return eType.grades;
            }
        }
        return new BigDecimal(0);
    }
}
